<template>
	<view class="file-box">
		<view class="file-content">
			<view class="file-title">{{fileData.noticeTitle}}</view>
			<view class="file-date">{{fileData.createTime}}</view>
			<view class="file-details">
				{{fileData.noticeContent}}
			</view>
			<view class="file-pdf" v-if="fileUrl">
				<!-- <image src="../../static/iconPdf.png" style="width: 32rpx;height: 32rpx;margin-top: 8rpx;"></image> -->
				<u-icon name="file-text-fill" style="width: 40rpx;height: 40rpx;margin-top: 8rpx;" size="20"
					color="#3473F9"></u-icon>
					<view class="cob ml35" @click="checkAttac(fileData.id,'0909')">查看相关附件</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileData: {},
				fileUrl: '',
			}
		},
		onLoad(options) {
			this.fileData = JSON.parse(options.data)
			// 获取pdf
			this.getPdf()
		},
		mounted() {
			this.noticeRead()
		},
		methods: {
			async noticeRead(){
				let params = {
					noticeId:this.fileData.id
				}
				let res =  await this.request(this.$api.noticeRead,params,'GET')
				console.log(res)
			},
			getPdf() {
				let that = this
				let fileData = that.fileData
				let params = {
					connectId: fileData.id,
					classify: '0909',
				}
				that.request(that.$api.getDownloadUrl, params, 'POST').then((res) => {
					console.log(res)
					if (res.code == 200) {
						that.fileUrl = res.resultValue[0]
						console.log('that.fileUrl',that.fileUrl)
					}
				})
			},
			//预览
			checkAttac(id, classify) {
				uni.navigateTo({
					url: './../../pagesB/checkTheAttachment/checkTheAttachment?classify=' + classify + '&connectId=' + id
				})
			}
		}
	}
</script>

<style>
	.file-box {
		/* height: 100vh; */
		background: #F1F2F5;
		box-sizing: border-box;
		padding: 20rpx 0 0 0;
	}

	.file-content {
		background-color: #fff;
		padding: 40rpx 40rpx;
		box-sizing: border-box;
	}

	.file-title {
		font-size: 34rpx;
		color: #000000;
		font-family: PingFangSC-Medium;
		font-weight: 600;
		text-align: center;
	}

	.file-date {
		margin-top: 6rpx;
		font-size: 30rpx;
		color: #999999;
		font-family: PingFangSC-Medium;
		font-weight: Regular;
		text-align: center;
	}

	.file-details {
		text-indent: 2em;
		text-align: left;
		font-size: 28rpx;
		color: #666666;
		font-family: PingFangSC-Medium;
		font-weight: Regular;
		margin-top: 30rpx;
	}

	.file-pdf {
		margin-top: 40rpx;
		display: flex;
		align-items: center;
		font-size: 28rpx;
		font-family: PingFangSC-Regular;
		font-weight: Regular;
	}
	.cob{
		color: #3473F9;
	}
</style>
